import { defineUserConfig } from '@vuepress/cli'
import { defaultTheme } from '@vuepress/theme-default'
import { searchPlugin } from '@vuepress/plugin-search'

export default defineUserConfig({
  // 继承默认主题
  dest: './me-utils-doc',
  base: '/me-utils/',
  // 站点配置
  lang: 'zh-CN',
  title: 'me-utils',
  description: '🛠 基于 TypeScript 开发的、简易的、模块化的 JavaScript 实用工具函数库',
  head: [['link', { rel: 'icon', href: '/me-utils/images/favicon.ico' }]],

  theme: defaultTheme({
    docsDir: 'docs',
    logo: '/images/logo.png',
    repoLabel: 'Gitee',
    repo: 'https://gitee.com/emrys-cloud/me-utils',
    notFound: ['未能找到您想要访问的页面'],
    backToHome: '返回首页',
    toggleDarkMode: '切换到夜间模式',
    nprogress: true,
    editLinkText: '在 Gitee 上编辑此页',
    contributorsText: '贡献者',
    lastUpdatedText: '最后更新时间',

    navbar: [
      {
        text: '快速上手',
        link: '/guide/',
      },
      {
        text: '了解更多',
        children: [
          {
            text: 'me-utils',
            children: [
              '/help/',
              {
                text: 'npm',
                link: 'https://www.npmjs.com/package/@emrys-cloud/me-utils',
              },
            ],
          },
          {
            text: '关于作者',
            children: [
              {
                text: 'Myrddin Emrys',
                link: 'https://emrys.cloud',
              },
              {
                text: '语雀',
                link: 'https://www.yuque.com/me-note',
              },
              {
                text: 'Gitee',
                link: 'https://gitee.com/emrys-cloud',
              },
              {
                text: 'Github',
                link: 'https://github.com/emrys-cloud',
              },
            ],
          },
        ],
      },
    ],

    sidebar: {
      '/guide/': [
        {
          text: '快速上手',
          collapsible: false,
          link: '/guide/',
        },
        {
          text: '✡️ 核心',
          collapsible: true,
          children: [
            {
              text: '🔮 类型',
              link: '/guide/core/types/',
            },
            {
              text: '🔮 字符串',
              link: '/guide/core/string/',
            },
            {
              text: '🔮 正则表达式',
              link: '/guide/core/regexp/',
            },
            {
              text: '🔮 数字',
              link: '/guide/core/number/',
            },
            {
              text: '🔮 数组',
              link: '/guide/core/array/',
            },
          ],
        },
        {
          text: '🌎️ 浏览器',
          collapsible: true,
          children: [
            {
              text: '🏔 页面适配',
              link: '/guide/web/adapt/',
            },
            {
              text: '🏔 剪贴板',
              link: '/guide/web/clipboard/',
            },
            {
              text: '🏔 设备',
              link: '/guide/web/device/',
            },
            {
              text: '🏔 文件',
              link: '/guide/web/file/',
            },
            {
              text: '🏔 URL',
              link: '/guide/web/url/',
            },
          ],
        },
      ],
      '/help/': [
        {
          text: '常见问题',
          link: '/help/',
        },
      ],
    },
  }),

  plugins: [
    [
      searchPlugin({
        locales: {
          '/': {
            placeholder: '搜索',
          },
        },
        // 排除首页
        isSearchable: page => page.path !== '/',
      }),
    ],
  ],
})
